﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ArtemisExtensions
{
    public abstract class EntitySystem : ArtemisExtensions.IEntitySystem
    {
        public static Universe Universe
        {
            get
            {
                throw new System.NotImplementedException();
            }
            set
            {
            }
        }

        public static SupportingEntitySystemManager SupportingEntitySystem
        {
            get
            {
                throw new System.NotImplementedException();
            }
            set
            {
            }
        }

        /// <summary>
        /// Execute the routine that this System implements
        /// </summary>
        /// <remarks>ie: if the system is to check everyone is alive, and otherwise delete them, then iterates through the info and makes the appropriate changes</remarks>
        public void Update()
        {
            if (!TriggerCondition())
            {
                //if not the condition, then don't run
                return;
            }

            //run the update routine
            UpdateRoutine();
        }

        /// <summary>
        /// Retrieve list of components of type t
        /// </summary>
        /// <returns>A list of components with type t</returns>
        protected List<IComponent> GetComponents(Type t)
        {
            return Universe.ComponentManager.GetAllComponents(t);
        }

        public abstract void UpdateRoutine();

        /// <summary>
        /// returns true if time to run ES, false if not
        /// </summary>
        protected abstract bool TriggerCondition();
    }
}
